package com.ailargemodel.common;

import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;


import java.io.Serializable;

/**
 * 通用返回类
 * @param <T>
 * @author 喜洋洋
 */
@Data
//@Builder
@NoArgsConstructor
public class BaseResponse<T> implements Serializable {
//    需要返回的信息
    private String msg;
//    需要的返回的 对象
    private T Data;
//    需要返回的状态码等等
    private Integer code;
    private String description;

/*//    try 单例模式
    private static BaseResponse Instance = new BaseResponse();

    public  static BaseResponse getInstance(){
        return Instance;
    }*/


    public BaseResponse(T data) {
        Data = data;
    }

    public BaseResponse(String msg, T data) {
        this.msg = msg;
        Data = data;
    }

    public BaseResponse(String msg) {
        this.msg = msg;
    }

    public BaseResponse(String msg, T data, Integer code) {
        this.msg = msg;
        Data = data;
        this.code = code;
    }

    public BaseResponse(String msg, T data, Integer code, String description) {
        this.msg = msg;
        Data = data;
        this.code = code;
        this.description = description;
    }

    public BaseResponse(String msg, Integer code) {
        this.msg = msg;
        this.code = code;
    }

    public BaseResponse(Integer code, String msg,  String description) {
        this.msg = msg;
        this.code = code;
        this.description = description;
    }

    public BaseResponse(ErrorCode errorCode){
        this(errorCode.getCode(), errorCode.getMessage(), errorCode.getDescription());
    }
}
